"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
var app = getApp();
exports.default = Page({
  data: {
    isShowBtn: false,
    isShowPay: false,
    isExtract: false,
    status: "1"
  },
  onLoad: function onLoad(e) {
    var mid = e.mid;
    var _this = this;
    var type = e.type;
    var header = JSON.parse(e.header);
    var openid = wx.getStorageSync("openid");
    wx.setNavigationBarTitle({
      title: type
    });
    _this.setData({
      header: header
    });
    wx.request({
      url: app.globalData.host,
      data: {
        mod: "record",
        act: "list",
        ssid: openid,
        opt: mid
      },
      method: "post", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function success(res) {
        // success
        console.log(res);
        _this.setData({
          mid: mid,
          openid: openid,
          recordList: res.data.info || ""
        });
      }
    });
    if (type == "积分记录") {
      this.setData({
        isShowBtn: true
      });
    }
    if (type == "交易记录") {
      this.setData({
        isShowPay: true
      });
    }
    if (type == "提现记录") {
      this.setData({
        isExtract: true
      });
    }
  },
  setStyle: function setStyle(e) {
    var _this = this;
    var type = e.currentTarget.dataset.class;
    wx.request({
      url: app.globalData.host,
      data: {
        mod: "record",
        act: "list",
        ssid: _this.data.openid,
        opt: _this.data.mid,
        type: e.currentTarget.dataset.type
      },
      method: "post", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function success(res) {
        // success
        //console.log(res)
        _this.setData({
          status: type,
          recordList: res.data.info
        });
      }
    });
  },
  linkPay: function linkPay(e) {
    var mid = e.currentTarget.dataset.mid;
    var name = e.currentTarget.dataset.name;
    var price = e.currentTarget.dataset.price;
    var activity = e.currentTarget.dataset.activity;
    wx.navigateTo({
      url: "pay/pay?price=" + price + "&mid=" + mid + "&name=" + name + "&activity=" + activity,
      success: function success(res) {
        // success
      },
      fail: function fail() {
        // fail
      },
      complete: function complete() {
        // complete
      }
    });
  },
  linkRecharge: function linkRecharge() {
    wx.navigateTo({
      url: "rechargePoints/rechargePoints",
      success: function success(res) {
        // success
      },
      fail: function fail() {
        // fail
      },
      complete: function complete() {
        // complete
      }
    });
  }
});